
import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import java.net.InetAddress;
import java.net.InetSocketAddress;

public class RPCServer {
    public static void main(String[] args) throws IOException {

      /*
        RPC.Builder builder = new RPC.Builder(new Configuration());
        builder.setBindAddress("127.0.0.1");
        builder.setPort(12345);

        builder.setProtocol(MyInterface.class);
        builder.setInstance(new MyInterfaceImpl());

        try {
            RPC.Server server = builder.build();
            server.start();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

       */

        Configuration configuration = new Configuration();
        RPC.Builder builder = new RPC.Builder(configuration);

        RPC.Server server = builder.setBindAddress("localhost")
                .setPort(4893)
                .setProtocol(MyInterface.class)
                .setInstance(new MyInterfaceImpl())
                .build();
        server.start();

        System.out.println("Service up!");

    }


}